package com.byComputer.bo;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.byComputer.util.HbnUtil;
import com.byComputer.vo.Computer;
import com.sun.java.swing.plaf.windows.WindowsInternalFrameTitlePane.ScalableIconUIResource;

public class ComputerService {

	/**
	 * @findComputer
	 * @return
	 */
	public List<Computer> findAddComputer() {
		Session s = HbnUtil.getSession();
		Query query = s.createQuery("from Computer");
		List<Computer> computerList = query.list();
		return computerList;

	}

	/**
	 * @getComputer 
	 * @param computerId
	 * @return
	 */
	public Computer getComputer(Integer computerId) {
		Session s = HbnUtil.getSession();
		String hql = "from Computer c where c.id=" + computerId;
		Query query = s.createQuery(hql);
		Computer computer = (Computer) query.uniqueResult();
		s.close();
		return computer;
	}
	
	public static void main(String[] args) {
		ComputerService cService = new ComputerService();
		Computer computer = cService.getComputer(1);
		System.out.println(computer.getDescription());
	}
}
